<template>
    <div class="app-container">
      <el-form :model="queryParams" class="frominfo" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
        <div class="from-item">
          <el-form-item label="账户名称" prop="account">
            <el-input v-model="queryParams.account" @keyup.enter.native="handleQuery" placeholder="请输入账户名称" clearable/>
          </el-form-item>
        </div>
        <div class="from-Btn">
          <el-form-item>
              <el-button class="blue-button" type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </div>
      </el-form>
  
      <el-table v-loading="loading" :data="freeList" :header-cell-style="{ background: '#fcfcfd', color: '#000' }" :border="false">
      
        <!-- <el-table-column label="微信用户id" prop="wcId" align="center" :show-overflow-tooltip="true"/>
        <el-table-column label="助手id" prop="assistId" align="center" :show-overflow-tooltip="true"/> -->
        <el-table-column label="账户名称" prop="account" align="center" :show-overflow-tooltip="true"/>
        
        <el-table-column label="key" prop="key" align="center" :show-overflow-tooltip="true"/>
        <el-table-column label="自动解除时间" prop="remainingTime" align="center" :show-overflow-tooltip="true" width="180">
              <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.remainingTime, '{y}-{m}-{d} {h}:{i}') }}</span>
              </template>
        </el-table-column>
        
        <el-table-column align="center" width="120" class-name="small-padding fixed-width">
          <template slot="header">
            <span>解冻</span>
            <el-tooltip class="item" effect="dark" content="进入操作" placement="top">
              <i class="el-icon-warning" style="color:#818e96;"></i>
            </el-tooltip>
          </template>
          <template slot-scope="scope">
           <span style="color:#0078fb;cursor: pointer;" @click="getEide(scope.row)">解冻</span>
          </template>
        </el-table-column>
        
      </el-table>
  
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  
    </div>
  </template>
  
  <script>
  
  import request from '@/utils/request'
  export default {
    name: "WcGroupsInfo",
    dicts: ['sys_friend_proport'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 表格数据
        freeList: [],
        // 是否显示弹出层
        open: false,
        chatTime:[],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          account: null,
        },
      };
    },
    created() {
    },
    mounted() {
      this.getList();
    },
    methods: {
      /** 查询微信群信息列表 */
      getList() {
        this.loading = true;
        getFreezeList(this.queryParams).then(res => {
          //console.log(res)
          if (res['success']) {
            const dt = res['data'];
            // this.total = dt['total'];
            // this.freeList = dt['records'];
            this.freeList = dt
          }
          this.loading = false;
        });
        setTimeout(()=>{
          this.loading = false;
        },2000)
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.beginTime=null
        this.queryParams.endTime=null
        if(this.chatTime!=''&&this.chatTime!=null){
          this.queryParams.beginTime=this.chatTime[0]+' 00:00:00'
          this.queryParams.endTime=this.chatTime[1]+' 23:59:59'
        }
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.chatTime=[]
        this.handleQuery();
      },
      getEide(row){
        var id=row.account
        unfreeze(id).then(res => {
           //console.log(res)
           this.$modal.msgSuccess("修改成功");
           this.getList()
        });
      },
    }
  };
  
  /** js请求 调用 */
  
  //获取用户列表
  export function getFreezeList(query) {
   return request({
     url: '/monitor/cache/getFreezeList',
     method: 'get',
     params: query
   })
  }
  //解冻账户
  export function unfreeze(id) {
   return request({
     url: '/monitor/cache/unfreeze/'+id,
     method: 'get',
   })
  }
  </script>
  <style scoped lang="scss">
    .app-container{
      background-color: #f6f9fb;
    }
    .frominfo{
      display: flex;background-color: #fff;padding: 10px;padding-bottom: 0; margin-bottom: 20px;
      .from-item{
        display: flex;flex-wrap: wrap;width: 80%;
      }
      .from-Btn{
        display: flex;flex-direction: column;align-items: center;justify-content: center;width: 20%;
      }
    }
    .blue-button {
      color: #fff;
      background-color: #0078fb;
      border-color: #0078fb;
    }
    
  </style>